/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.biblioteca.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.biblioteca.Categoriadelibro;
import mx.its.dsw2.biblioteca.Libro;

/**
 *
 * @author Carlos Asis
 */
@Stateless
public class CategoriadelibroFacade extends AbstractDao<Categoriadelibro> implements CategoriadelibroFacadeLocal {
    @PersistenceContext(unitName = "Biblioteca-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoriadelibroFacade() {
        super(Categoriadelibro.class);
    }
    
     @Override
    public List<Categoriadelibro> getByLibro(Libro book) {
        Query q = em.createNamedQuery("Categoriadelibro.findByIdLibro");
        q.setParameter("idLibro", book.getId());
        return q.getResultList();
    }
    
}
